<?php
  
  
  class css {
      
      
      
      static function changeCssProperty($filename, $class, $attribute, $value) {
          
          
          $css = file::readTextFile($filename);
          
                                  //\#
          
          
          $class = re::getRegex("($class.*?\{.*?\})", $css);
          $classOrginal = $class;
          
          if ($class == "") {
              
              $class = "$class { }";
              
          }
          
          
          
          
          
          $propertyOrginal = re::getRegex("($attribute:.*?;)", $class);

          
          if ($propertyOrginal == "") {
              
              $propertyOrginal = "$attribute:old_value;";
              $class = str_replace('}', $propertyOrginal."}" , $class);
              
              
          }
          
          
          $propertyValue = re::getRegex("$attribute:(.*?);", $class);
          $propertyNew = str_ireplace($propertyValue, $value, $propertyOrginal);

          //echo $propertyNew;
          
          $classNew = str_ireplace($propertyOrginal, $propertyNew, $class);
          
          //echo "********".$classNew;
          $css = str_ireplace($classOrginal, $classNew, $css);
          
          //echo $css;
          
          file::createTextFile($filename, $css);
          

          //echo $propertyValue;
          
          
      }
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      static function importCssConfig() {
          
                db::emptyTable("_css_class");
          
          
                 $folder = new folder();
                 $folder->getFolder("/snapol/css_config");
                 
                 do {
                     
                     
                     
                     echo $folder->data['full_filename']."<br>";
                     
                     $css = file::readTextFileArray($folder->data['full_filename']);
                     $element = file::getFilenameText($folder->data['filename']);
                     
                     for ($n=0; $n<sizeof($css); $n++) {
                         
                         $data = array();
                         $data['class'] = $css[$n];
                         $data['element'] = $element;
                         db::saveData("_css_class", $data);
                         
                         
                         
                         
                     }
                     
                     
                     
                     
                 } while($folder->nextRow());
          
          
          
          
          
          
          
      }
      
      
      
      
      
      
      function importCss() {
          
          $css = file::readTextFile("/css/first.css");
          
          
          
          //echo $css;
          
          
          $reg = new regex();
          
          $reg->getRegexTable("\.(.*?)\{.*?\}", $css);
          
          do {
              
              echo $reg->data[0]."<br>";
              
              $data = array();
              $data['class'] = $reg->data[0];
              db::saveData("_css_class", $data);
              
              
              
          } while($reg->nextRow());
          
         
          
          
          
          
      }
      
      
      
       
      
      
      
      
  }
  
  
  
  
  
  
  
  
  
  
  
  
?>
